home *** CD-ROM | disk | FTP | other *** search
/ Complete Linux / Complete Linux.iso / docs / apps / database / ingres04.lzh / source / gutil / set_so_buf.c < prev    next >
Encoding:
C/C++ Source or Header  |  1993-01-18  |  814 b   |  43 lines

  1. # include    <stdio.h>
  2. # include    <errno.h>
  3. # include    <ingres.h>
  4. # include    <sccs.h>
  5.  
  6. SCCSID(@(#)set_so_buf.c    8.1    12/31/84)
  7.  
  8. /*
  9. **  SET_SO_BUF -- set standard output buffer conditionally
  10. **
  11. **    This routine sets the standard output buffer conditionally,
  12. **    based on whether or not it is a terminal.  If it is, it
  13. **    does not set the output; otherwise, it buffers the output.
  14. **    The buffer is contained internally.
  15. **
  16. **    Parameters:
  17. **        none
  18. **
  19. **    Returns:
  20. **        TRUE -- if buffer was set
  21. **        FALSE -- otherwise
  22. **
  23. **    Side Effects:
  24. **        The standard output is left buffered or unchanged.
  25. */
  26.  
  27. set_so_buf()
  28. {
  29.     static char    buffer[BUFSIZ];
  30.  
  31.     /* check for standard output is tty */
  32.     if (isatty(fileno(stdout)))
  33.     {
  34.         /* no: reset errno and buffer */
  35.         errno = 0;
  36.         setbuf(stdout, buffer);
  37.  
  38.         return (TRUE);
  39.     }
  40.  
  41.     return (FALSE);
  42. }
  43.